import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const types = {
  SET_IS_AUTNENTIATED: 'SET_IS_AUTNENTIATED', // 是否认证通过
  SET_USER: 'SET_USER' // 用户信息
}

const state = {
  user: {}, //存储用户信息
  imgStr: "http://www.912cc.com",
  cozeList: [
    // {
    //   type: "in",
    //   content: "明天加班吗",
    //   contentType: "txt",
    //   icon: require("../assets/img/003.png")
    // },
    // {
    //   type: "out",
    //   content: "加啊 ",
    //   contentType: "txt",
    //   icon: require("../assets/img/003.png")
    // },
    // {
    //   type: "in",
    //   content: "哈哈哈哈",
    //   contentType: "txt",
    //   icon: require("../assets/img/003.png")
    // },
    // {
    //   type: "out",
    //   content: require("../pages/friend/img/1.png"),
    //   contentType: "img",
    //   icon: require("../assets/img/003.png")
    // },
  ],
  currency: {
    ADA: require("../assets/imgBTC/ADA.png"),
    BCH: require("../assets/imgBTC/BCH.png"),
    BTC: require("../assets/imgBTC/BTC.png"),
    EOS: require("../assets/imgBTC/EOS.png"),
    LTC: require("../assets/imgBTC/LTC.png"),
    PS: require("../assets/imgBTC/ps.png"),
    TRX: require("../assets/imgBTC/TRX.png"),
    XLM: require("../assets/imgBTC/XLM.png"),
    XRP: require("../assets/imgBTC/XRP.png"),
    ETH: require("../assets/imgBTC/ETH.png"),
    MIOTA: require("../assets/imgBTC/MIOTA.png"),
    HIW: require("../assets/imgBTC/HIW.png")
  },
  forgetPage: false,
  addressPage: false,
  bagPayPage: false,
  robPage: false
}
const getters = {
  user: state => state.user,
  currency: state => state.currency,
  imgStr: state => state.imgStr,
  forgetPage: state => state.forgetPage,
  addressPage: state => state.addressPage,
  bagPayPage: state => state.bagPayPage,
  cozeList: state => state.cozeList,
  robPage: state => state.robPage
}
const mutations = {
  [types.SET_USER](state, user) {
    if (user) {
      state.user = user
    } else {
      state.user = {}
    }
  },
  isShowForget: (state, forgetPage) => {
    state.forgetPage = !state.forgetPage
  },
  isShowAddress: (state, addressPage) => {
    state.addressPage = !state.addressPage
  },
  isShowbagPay: (state, bagPayPage) => {
    state.bagPayPage = !state.bagPayPage
  },
  isRobPage: (state, robPage) => {
    state.robPage = !state.robPage
  },
  addcozeItem: (state, newItem) => {
    const item = {
      type: "out",
      content: "55555",
      icon: require("../assets/img/003.png")
    }
    state.cozeList.push(Object.assign(item, newItem))
  },
  cleanCozeItem: (state) => {
    state.cozeList = []
  }
}
const actions = {
  setUser: ({
    commit
  }, user) => {
    commit(types.SET_USER, user)
  },
  isShowForget: ({
    commit
  }, forgetPage) => {
    commit('isShowForget', forgetPage)
  },
  isShowAddress: ({
    commit
  }, addressPage) => {
    commit('isShowAddress', addressPage)
  },
  isShowbagPay: ({
    commit
  }, bagPayPage) => {
    commit("isShowbagPay", bagPayPage)
  },
  isRobPage: ({
    commit
  }, robPage) => {
    commit("isRobPage", robPage)
  },
  addcozeItem: ({
    commit
  }, newItem) => {
    commit("addcozeItem", newItem)
  },
  cleanCozeItem: ({
    commit
  }, newItem) => {
    commit("cleanCozeItem", newItem)
  },

}

export default new Vuex.Store({
  state,
  getters,
  mutations,
  actions
})
